package com.objis.demostruts;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class DemandeFormationForm extends ActionForm {

	public DemandeFormationForm() {
		super();
		setAudit("oui");
	}
	private String name=null;
	private String address=null;
	private String emailAddress=null;
	private String societe=null;
	private String theme=null;
	private String date=null;
	private String audit=null;
	private String remarque=null;
	
	public String getRemarque() {
		return remarque;
	}
	public void setRemarque(String remarque) {
		this.remarque = remarque;
	}

	public String getAudit() {
		return audit;
	}
	public void setAudit(String audit) {
		this.audit = audit;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getEmailAddress() {
		return emailAddress;
	}
	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}
	public String getSociete() {
		return societe;
	}
	public void setSociete(String societe) {
		this.societe = societe;
	}
	public String getTheme() {
		return theme;
	}
	public void setTheme(String theme) {
		this.theme = theme;
	}
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		ActionErrors errors = new ActionErrors();
		
		if( getName() == null || getName().length() < 1 ) {
			errors.add("name",new ActionMessage("error.name.required"));
		}
		if( getAddress() == null || getAddress().length() < 1 ) {
			errors.add("address",new ActionMessage("error.address.required"));
		}
		if( getEmailAddress() == null || getEmailAddress().length() < 1 ) {
			errors.add("emailaddress",new ActionMessage("error.emailaddress.required"));
		}
		if( getSociete() == null || getSociete().length() < 1 ) {
			errors.add("societe",new ActionMessage("error.societe.required"));
		}
		if( getTheme() == null || getTheme().length() < 1 ) {
			errors.add("theme",new ActionMessage("error.theme.required"));
		}
		if( getDate() == null  || getDate().length() < 1 ) {
			errors.add("date",new ActionMessage("error.date.required"));
		}
		if( getRemarque() == null || getRemarque().length() < 1 ) {
			errors.add("remarque",new ActionMessage("error.remarque.required"));
		}
		return errors;
	}
	
}
